<?
	include_once('header.php');

	include_once('sidebar.php');

	$edit = $_GET['edit'];
	$offset = $_GET['offset'];
	$limit = $_GET['limit'];
	$action = $_GET['action'];
	if(!$offset) { $offset = "0"; }
	if(!$limit) { $limit = "20"; }
	$new_post = $_POST['new_post'];
	$delete = $_GET['delete'];
	$update_options = drizzo_update_options();
?>

		<div id="main">

<?
	if($update_options == 2) {
		echo "\t\t\t\t<p class=\"save\">Options have been updated.</p>";
	} elseif($update_options == 1) {
		echo "\t\t\t\t<p class=\"alert\">Options could not be updated.</p>";
	}
?>			
			<h2><? echo ucwords(str_replace('_', ' ', $_GET['options'])) . " "; if(!$_GET['options']) { echo "General "; } ?>Options</h2>
			
				<form name="options_form" id="options_form" action="" method="post">
<?
	if(!$_GET['options']) { // General Options
		$site_name = stripslashes(drizzo_global_options("site_name"));
?>
					<label for="site_name">Site Name</label> <input type="text" name="site_name" value="<? echo $site_name; ?>" /><br class="clear" />
<?
		$site_description = stripslashes(drizzo_global_options("site_description"));
?>
					<label for="site_description">Site Description</label> <input type="text" name="site_description" value="<? echo $site_description; ?>" /><br class="clear" />
<?
		$permalinks = drizzo_global_options("permalink");
?>
					<label for="use_permalinks">Use Permalinks<a href="javascript:void(0)">?<span class="explain">Permalinks make your URLs appear as a series of folders (ie, http://drizzoblog.com/blog/welcome). If turned off your URLs will be in the form of 'http://drizzoblog.com/?id=1'.</span></a></label> <select name="use_permalinks">
						<option value="1"<? if($permalinks == '1') { echo " selected"; } ?>>Yes</option>
						<option value="0"<? if($permalinks == '0') { echo " selected"; } ?>>No</option>
					</select><br class="clear" />
<?
		$posts_per_page = drizzo_global_options("posts_per_page");
?>
					<label for="posts_per_page">Posts per page</label><input type="text" name="posts_per_page" value="<? echo $posts_per_page; ?>" /><br class="clear" />
					<label for="admin_css">Admin Style</label><? echo drizzo_admin_styles_dropdown(); ?>
					<hr class="rule" />
<?
		$timezone_offset = drizzo_global_options("timezone_offset");
?>
					<h3>Time &amp; Date</h3>
					<label for="gmt">Greenwich Mean Time (GMT)<a href="javascript:void(0)">?<span class="explain">Drizzo uses GMT as the base for all time and dates.</span></a></label> <? echo date('M d, Y - g:i A', time()-date('Z')); ?><br class="clear" />
					<label for="timezone_offset">Hour difference for the site's times<a href="javascript:void(0)">?<span class="explain">How many hours, plus or minus, is your local time to the GMT time above.</span></a></label> <input type="text" class="narrow" name="timezone_offset" value="<? echo $timezone_offset; if($timezone_offset == null) { echo str_replace('0','', date('O')); } ?>"/><br class="clear" />
<?
		$date_format = drizzo_global_options("date_format");
		if(!$date_format) {
			$date_format = "F d, Y";
		}
		$time_format = drizzo_global_options("time_format");
		if(!$time_format) {
			$time_format = "g:i A";
		}
?>
					<p>The Date and Time Formats use standard PHP date() function variables. <a href="http://us3.php.net/date" title="date() Documentation">Click here for date() documentation.</a></p>
					<label for="date_format">Date Format</label> <input type="text" name="date_format" value="<? echo $date_format; ?>"><br class="clear" />
					<label for="sample_date">Sample Date Output</label> <strong><? echo date($date_format); ?></strong> (Save Options to update)<br class="clear" />
					<label for="time_format">Time Format</label> <input type="text" name="time_format" value="<? echo $time_format; ?>"><br class="clear" />
					<label for="sample_time">Sample Time Output</label> <strong><? echo date($time_format); ?></strong> (Save Options to update)<br class="clear" />
<?
	} elseif($_GET['options'] == 'post') { // Posts Options
?>
					<h3>Autolinks</h3>
					<label for="autolinks">Use Automatic Links<a href="javascript:void(0)">?<span class="explain">If this option is turned on, any phrase matching the title of a link in your links list will be converted to a link.</span></a></label> <select name="autolinks"><option value="1"<? if(drizzo_global_options('autolinks') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('autolinks') == 0) { echo " selected"; } ?>>No</option></select><br class="clear" />
					<label for="autolinks">Case Sensitive<a href="javascript:void(0)">?<span class="explain">If this option is turned on, links will only be created when the phrase is exactly the same as the title in the links list. (IE, Drizzo will only match 'Drizzo' and not 'drizzo')</span></a></label> <select name="autolinks_case_sensitive"><option value="1"<? if(drizzo_global_options('autolinks_case_sensitive') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('autolinks_case_sensitive') == 0) { echo " selected"; } ?>>No</option></select><br class="clear" />
					<label for="autolinks_all">Convert Which Matches<a href="javascript:void(0)">?<span class="explain">'All' means every match will be converted while 'First' only converts the first occurrence.</span></a></label> <select name="autolinks_all"><option value="1"<? if(drizzo_global_options('autolinks_all') == 1) { echo " selected"; } ?>>All</option><option value="0"<? if(drizzo_global_options('autolinks_all') == 0) { echo " selected"; } ?>>First</option></select><br class="clear" />
					<hr class="rule" />
					<h3>Social Network Links</h3>
					<p>Select which Social Network Links you would like to be include in drizzo_social_links().</p>
					<label for="social_link_digg">Digg.com</label> <select name="social_link_digg"><option value="1"<? if(drizzo_global_options('social_link_digg') == 1) { echo " selected"; } ?>>Yes</option><option value="0"<? if(drizzo_global_options('social_link_digg') == 0) { echo " selected"; } ?>>No</option></select><br class="clear" />
					<label for="social_link_digg_size">Digg.com Button Size</label> <select name="social_link_digg_size"><option value="normal"<? if(drizzo_global_options('social_link_digg_size') == 'normal') { echo " selected"; } ?>>Normal</option><option value="compact"<? if(drizzo_global_options('social_link_digg_size') == 'compact') { echo " selected"; } ?>>Compact</option></select><br class="clear" />
<?		
	} elseif($_GET['options'] == 'comments') { // Comments Options
		
	} elseif($_GET['options'] == 'theme') { // Theme Options
		$theme = drizzo_global_options("theme");
		$theme_info = drizzo_theme_info();
?>
					<h3>Current Theme</h3>
					<div class="theme_thumb" id="theme_thumb_selected">
						<a href="javascript:void(0);" onclick="$('theme_thumb_selected').id = '';$(this).parentNode.id = 'theme_thumb_selected';document.options_form.theme_input.value = '<? echo $theme; ?>';" title="Select This Theme"><img src="<? echo $theme_info['screenshot']; ?>" alt="Theme Preview" width="300" height="170" />
						<p><strong><? echo $theme_info['theme'] . " " . $theme_info['version']; ?></strong><br />
						<em>Author:</em> <? echo $theme_info['author']; ?><br />
						<em>URL:</em> <? echo $theme_info['url']; ?></p></a>
					</div>
					<input type="hidden" name="theme" value="<? echo $theme; ?>" id="theme_input" />
					<br class="clear" />
					<div class="rule"></div>
					<h3>Available Themes <em>(Click to select)</em></h3>
<?
		$themes_list = drizzo_list_valid_themes();
		if($themes_list) {
			foreach($themes_list as $themes) {
?>
					<div class="theme_thumb" id="">
						<a href="javascript:void(0);" onclick="$('theme_thumb_selected').id = '';$(this).parentNode.id = 'theme_thumb_selected';document.options_form.theme_input.value = '<? echo strtolower($themes['theme']); ?>';" title="Select This Theme"><img src="<? echo $themes['screenshot']; ?>" alt="Theme Preview" width="300" height="170" />
						<p><strong><? echo $themes['theme'] . " " . $themes['version']; ?></strong><br />
						<em>Author:</em> <? echo $themes['author']; ?><br />
						<em>URL:</em> <? echo $themes['url']; ?></p></a>
					</div>
<?
			}
		} else {
			echo "<p>There are no valid themes available.</p>";
		}
		$invalid_themes = drizzo_list_invalid_themes();
		if($invalid_themes) {
?>
					<br class="clear" />
					<div class="rule"></div>
					<h3>Partial Themes</h3>
<?
			foreach($invalid_themes as $invalid_theme) {
?>
					<p class="invalid_theme"><strong><? echo $invalid_theme['theme']; ?></strong> <? echo $invalid_theme['error']; ?></p>
<?
			}
		}
	} elseif($_GET['options'] == 'miscellaneous') { // Miscellaneous Options
		
	} else { // Unsupported Options
?>
					<p>This Options module is not yet supported.</p>
<?
	}
?>			
					<br class="clear" />
					<p class="center"><input type="submit" class="submit" name="submit" value="Save Options" /></p>
				</form>

			<br class="clear" />
			
		</div>
<?
	include_once('footer.php');
?>